<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../lib/vue.js"></script>
</head>
<body>
    <div id="app">
        <h3 v-color="'green'">app</h3>
        <One></One>
    </div>
</body>
<script>
    // Vue.directive("color",function(el,binds){
    //     el.style.color = binds.value;
    // })

    Vue.directive("color",{
        // el:element --> binds:arg
        bind(el,binds){
            el.style.color = binds.value;
        }
    })
    new Vue({
        el: "#app",
        components: {
            One: {
                data() {
                    return {
                        str: "字符串",
                        red:"red"
                    }
                },
                template: (`
                    <p v-color="red">{{str}}</p>
                `),
                // 局部指定，在哪里声明只允许在哪里使用
                // directives:{
                //     color(el,binds){
                //         el.style.color = binds.value;
                //     }
                // }
            }

        }
    })
</script>
</html>